extern crate imgui; 

pub struct Window {
    str_js : String,
    opened : bool,
}

impl Window {
    pub fn new()->Window {
        Window {
            str_js : String::from(""),
            opened: true
        }
    }

    pub fn render(&mut self, ui : &imgui::Ui) {
        let mut str = imgui::ImString::with_capacity(100);
        if !self.opened {return;}
        let w = imgui::Window::new(imgui::im_str!("imgui"))
            .opened(&mut self.opened).size([800.0,600.0], imgui::Condition::FirstUseEver)
            // .flags(imgui::WindowFlags::NO_RESIZE | imgui::WindowFlags::NO_TITLE_BAR)
            .position_pivot([0.5, 0.5])
            ;
        match w.begin(&ui) {
            Some(token) => {
                ui.popup(imgui::im_str!("Popup_Info"), || {
                    ui.text(imgui::im_str!(str_js));
                    if ui.button(imgui::im_str!("关闭"), [80.0, 25.0]) {
                        ui.close_current_popup();
                    }
                });
                if ui.input_text(imgui::im_str!(""), &mut str).build() {
                    self.str_js = str.to_string();
                    println!("str_js is: {}", self.str_js);
                }
                ui.same_line(10.0);
                if ui.button(imgui::im_str!("Confirm"), [80.0,25.0]) {
                    ui.open_popup(imgui::im_str!("Popup_Info"));
                }
                token.end(&ui);
            },
            _ => {}
        }
    }
}